home *** CD-ROM | disk | FTP | other *** search
Wrap
public class TrapCloseRoom extends Codex { private CodexRegion _trapRegion = new CodexRegion(((Codex)this).GetClassThing()); private CodexThing _rotateDoor1; private CodexThing _rotateDoor2; private int _numberOfEnemies; private String _enemy1Type = ""; private String _enemy2Type = ""; private String _enemy3Type = ""; private String _enemy4Type = ""; private String _enemy5Type = ""; private CodexThing _spawn1; private CodexThing _spawn2; private CodexThing _spawn3; private CodexThing _spawn4; private CodexThing _spawn5; private int _enemiesDead; private int initiatorGuid; private boolean _bTrapOn = true; private boolean _bClosed = true; private boolean bSpawned; public static String[] _params = new String[]{"Rotate door 1", "Rotate door 2", "Number of enemies needed to kill;5", "Enemy 1 type (template name)", "Enemy 2 type (template name)", "Enemy 3 type (template name)", "Enemy 4 type (template name)", "Enemy 5 type (template name)", "Spawn 1", "Spawn 2", "Spawn 3", "Spawn 4", "Spawn 5"}; public TrapCloseRoom(CodexThing rotateDoor1, CodexThing rotateDoor2, int numberOfEnemies, String enemy1Type, String enemy2Type, String enemy3Type, String enemy4Type, String enemy5Type, CodexThing spawn1, CodexThing spawn2, CodexThing spawn3, CodexThing spawn4, CodexThing spawn5) { this._rotateDoor1 = new CodexThing(((Codex)rotateDoor1).GetGUID()); this._rotateDoor2 = new CodexThing(((Codex)rotateDoor2).GetGUID()); this._numberOfEnemies = numberOfEnemies; this._enemy1Type = enemy1Type; this._enemy2Type = enemy2Type; this._enemy3Type = enemy3Type; this._enemy4Type = enemy4Type; this._enemy5Type = enemy5Type; this._spawn1 = new CodexThing(((Codex)spawn1).GetGUID()); this._spawn2 = new CodexThing(((Codex)spawn2).GetGUID()); this._spawn3 = new CodexThing(((Codex)spawn3).GetGUID()); this._spawn4 = new CodexThing(((Codex)spawn4).GetGUID()); this._spawn5 = new CodexThing(((Codex)spawn5).GetGUID()); ((Codex)this).CaptureThing(this._trapRegion.GetGUID()); ((Codex)this).CaptureThing(this._rotateDoor1.GetGUID()); ((Codex)this).CaptureThing(this._rotateDoor2.GetGUID()); if (this._rotateDoor1.GetDescriptionID().equalsIgnoreCase("PROP")) { this._rotateDoor1.SetDescriptionID("GEN_DOOR"); } if (this._rotateDoor2.GetDescriptionID().equalsIgnoreCase("PROP")) { this._rotateDoor2.SetDescriptionID("GEN_DOOR"); } } public void clicked(int guid, int clickerGuid, int captureID) { if (guid == this._rotateDoor1.GetGUID() && this._bTrapOn) { if (this._bClosed) { this._rotateDoor1.RotatePivot(1, 3.0F); this._bClosed = false; } else if (!this._bClosed) { this._rotateDoor1.RotatePivot(1, -3.0F); this._bClosed = true; } } else { new CodexSound("locked_large_02.WAV", 300.0F, 600.0F, 100, 0, 0, guid); CodexConsole.PrintNLS(CodexPlayer.GetCurrentPlayer(), 0, "GEN_DOORLOCKED"); } } public void beginscene(int clientGuid, int captureID) { if (!this.bSpawned) { this._rotateDoor1.SetThingFlags(8192); this._rotateDoor2.SetThingFlags(8192); for(int i = 0; i < this._numberOfEnemies; ++i) { switch (i) { case 0: ((Codex)this).CaptureThing(this._spawn1.SpawnThing(this._enemy1Type)); break; case 1: ((Codex)this).CaptureThing(this._spawn2.SpawnThing(this._enemy2Type)); break; case 2: ((Codex)this).CaptureThing(this._spawn3.SpawnThing(this._enemy3Type)); break; case 3: ((Codex)this).CaptureThing(this._spawn4.SpawnThing(this._enemy4Type)); break; case 4: ((Codex)this).CaptureThing(this._spawn5.SpawnThing(this._enemy5Type)); } } this.bSpawned = true; } } public void restore(int flags) { this._bTrapOn = CodexSequence.RestoreBoolean(); this._bClosed = CodexSequence.RestoreBoolean(); this.bSpawned = CodexSequence.RestoreBoolean(); this._enemiesDead = CodexSequence.RestoreInt(); this._numberOfEnemies = CodexSequence.RestoreInt(); } public void entered(int guid, int causeGUID, int captureID) { if (Codex.IsPlayerGuid(causeGUID) && this._bTrapOn && !this._bClosed) { this.initiatorGuid = causeGUID; ((Codex)this).CaptureThing(this.initiatorGuid); this._rotateDoor1.RotatePivot(1, -1.0F); this._bTrapOn = false; this._bClosed = true; ((Codex)this).SetTimer(45.0F); } } public void killed(int guid, int causeID, int captureID) { if (guid == this.initiatorGuid || ++this._enemiesDead == this._numberOfEnemies) { ((Codex)this).KillAllTimers(); this._rotateDoor1.RotatePivot(1, 1.0F); this._rotateDoor2.RotatePivot(1, 1.0F); this._enemiesDead = 10; } } public void save(int flags) { CodexSequence.SaveBoolean(this._bTrapOn); CodexSequence.SaveBoolean(this._bClosed); CodexSequence.SaveBoolean(this.bSpawned); CodexSequence.SaveInt(this._enemiesDead); CodexSequence.SaveInt(this._numberOfEnemies); } public void timer(int timerID, float arg0, float arg1, float arg2, float arg3) { this._enemiesDead = 10; this._rotateDoor1.RotatePivot(1, 1.0F); this._rotateDoor2.RotatePivot(1, 1.0F); } }